package biz.impl;

import java.util.List;

import biz.AreaBiz;
import dao.AreaDao;
import dao.StreetDao;
import dao.impl.AreaDaoImpl;
import dao.impl.StreetDaoImpl;
import entity.Area;
import entity.Street;

public class AreaBizImpl implements AreaBiz {
	private AreaDao areaDao = new AreaDaoImpl();
	private StreetDao streetDao = new StreetDaoImpl();
	@Override
	public List<Area> queryStreetOfEachArea() {
		List<Area> areaList = areaDao.queryAllArea();
		for (Area area : areaList) {
			List<Street> streetList = streetDao.queryStreetByAreaId(area.getAreaId());
			if(streetList!=null)
				area.setStreetList(streetList);
		}
		return areaList;
	}

	@Override
	public Area queryStreetOfAreaByAreaId(int areaId) {
		Area area = areaDao.queryAreaByAreaId(areaId);
		List<Street> streetList = streetDao.queryStreetByAreaId(area.getAreaId());
		if(streetList!=null)
			area.setStreetList(streetList);
		return area;
	}

}
